/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.liquidByte.trafficMustang.server.dataModel;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import org.liquidByte.trafficMustang.server.dataModel.enums.DeslocamentoSituacao;

/**
 *
 * @author Alexandre
 */
@Entity
@Table(name = "deslc")
public class Deslocamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "DESLC_ID", nullable = false)
    private Integer deslcId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "DESLC_TAX")
    private BigDecimal deslcTax;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DESLC_LOTC")
    private short deslcLotc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DESLC_DT_PART")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deslcDtPart;
    @Column(name = "DESLC_DT_CHEG")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deslcDtCheg;
    
    @Embedded
    @AttributeOverrides({
        @AttributeOverride(column=@Column(name="DESLC_LONG", nullable=false), name="longitude"),
        @AttributeOverride(column=@Column(name="DESLC_LAT", nullable=false), name="latitude")
    })
    private Localizacao localizacao;
    
    @JoinColumn(name = "VEIC_ID", referencedColumnName = "VEIC_ID")
    @ManyToOne(optional = false)
    private Veiculo veicId;
    @JoinColumn(name = "MOTR_ID", referencedColumnName = "USR_ID")
    @ManyToOne(optional = false)
    private Motorista motrId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DESLC_SIT_ID")
    @Enumerated(EnumType.ORDINAL)
    private DeslocamentoSituacao deslcSitId;
    @OneToMany(mappedBy = "deslcId")
    private List<Trecho> trechoList;

    public Deslocamento() {
        
    }

    public Deslocamento(Integer deslcId) {

        this.deslcId = deslcId;
    }

    public Deslocamento(Integer deslcId, BigDecimal deslcTax, short deslcLotc, Date deslcDtPart, Localizacao localizacao) {
        this();
        this.deslcId = deslcId;
        this.deslcTax = deslcTax;
        this.deslcLotc = deslcLotc;
        this.deslcDtPart = deslcDtPart;
        this.localizacao = localizacao;
    }

    public Integer getDeslcId() {
        return deslcId;
    }

    public void setDeslcId(Integer deslcId) {
        this.deslcId = deslcId;
    }

    public BigDecimal getDeslcTax() {
        return deslcTax;
    }

    public void setDeslcTax(BigDecimal deslcTax) {
        this.deslcTax = deslcTax;
    }

    public short getDeslcLotc() {
        return deslcLotc;
    }

    public void setDeslcLotc(short deslcLotc) {
        this.deslcLotc = deslcLotc;
    }

    public Date getDeslcDtPart() {
        return deslcDtPart;
    }

    public void setDeslcDtPart(Date deslcDtPart) {
        this.deslcDtPart = deslcDtPart;
    }

    public Date getDeslcDtCheg() {
        return deslcDtCheg;
    }

    public void setDeslcDtCheg(Date deslcDtCheg) {
        this.deslcDtCheg = deslcDtCheg;
    }

    public Localizacao getLocalizacao() {
        return localizacao;
    }

    public void setLocalizacao(Localizacao localizacao) {
        this.localizacao = localizacao;
    }

    public Veiculo getVeicId() {
        return veicId;
    }

    public void setVeicId(Veiculo veicId) {
        this.veicId = veicId;
    }

    public Motorista getMotrId() {
        return motrId;
    }

    public void setMotrId(Motorista motrId) {
        this.motrId = motrId;
    }

    public DeslocamentoSituacao getDeslcSitId() {
        return deslcSitId;
    }

    public void setDeslcSitId(DeslocamentoSituacao deslcSitId) {
        this.deslcSitId = deslcSitId;
    }

    public List<Trecho> getTrechoList() {
        return trechoList;
    }

    public void setTrechoList(List<Trecho> trechoList) {
        this.trechoList = trechoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (deslcId != null ? deslcId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Deslocamento)) {
            return false;
        }
        Deslocamento other = (Deslocamento) object;
        if ((this.deslcId == null && other.deslcId != null) || (this.deslcId != null && !this.deslcId.equals(other.deslcId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.liquidByte.trafficMustang.server.dataModel.Deslocamento[ deslcId=" + deslcId + " ]";
    }
    
}
